set scheme s2color

** Figure 1(a)

use "$project_path/data/3_cleaned/turnovers_presidential", clear
append using "$project_path/data/3_cleaned/turnovers_parliamentary_electoral"
merge m:1 Country using "$project_path/data/1_input/other/regions/regions", keep(match) assert(using match) nogen
keep Country Year Month Type_Election runvar treatment OECD
// We focus on the sample for which a running variable is available
replace treatment = . if runvar==.
gen treatment_oecd = treatment if OECD==1
gen treatment_not_oecd = treatment if OECD!=1
gen time_bin = Year - mod(Year,5)
collapse (mean) treatment treatment_oecd treatment_not_oecd, by(time_bin)
lab var treatment "Full sample"
lab var treatment_oecd "OECD"
lab var treatment_not_oecd "Non-OECD"
line  treatment treatment_oecd treatment_not_oecd time_bin, graphregion(color(white)) legend(size(medlarge) row(1) region(lwidth(none))) lwidth(thick thick thick) lpattern(solid dash_dot  shortdash) lcolor(navy navy%40  green%40) xlabel(1945(5)2015, angle(45) labsize(large)) ylabel(0(0.1)0.6 , angle(0) labsize(large)) xtitle("") ytitle("") /*title("Share of elections with an electoral turnover", size(large) placement(9) span)*/
graph export "$project_path/output/figures/Figure_1a.pdf", as(pdf) name("Graph") replace

** Figure 1(b)

use "$project_path/data/3_cleaned/turnovers_presidential", clear
append using "$project_path/data/3_cleaned/turnovers_parliamentary_executive"
merge m:1 Country using "$project_path/data/1_input/other/regions/regions", keep(match) assert(using match) nogen
drop if flag_inconsequential==1 | flag_coup==1 | flag_not_last==1
keep Country Year Month Type_Election runvar_alt treatment_alt OECD
// We focus on the sample for which a running variable is available
replace treatment_alt = . if runvar_alt==.
gen treatment_alt_oecd = treatment_alt if OECD==1
gen treatment_alt_not_oecd = treatment_alt if OECD!=1
gen time_bin = Year - mod(Year,5)
collapse (mean) treatment_alt treatment_alt_oecd treatment_alt_not_oecd, by(time_bin)
lab var treatment_alt "Full sample"
lab var treatment_alt_oecd "OECD"
lab var treatment_alt_not_oecd "Non-OECD"
line  treatment_alt treatment_alt_oecd treatment_alt_not_oecd time_bin, graphregion(color(white)) legend(size(medlarge) row(1) region(lwidth(none))) lwidth(thick thick thick) lpattern(solid dash_dot  shortdash) lcolor(navy navy%40  green%40) xlabel(1945(5)2015, angle(45) labsize(large)) ylabel(0(0.1)0.6 , angle(0) labsize(large)) xtitle("") ytitle("") /*title("Share of elections with a turnover in the executive branch", size(large) placement(9) span)*/
graph export "$project_path/output/figures/Figure_1b.pdf", as(pdf) name("Graph") replace

